"""
员工管理模块的 接口对象层
"""
import json

import requests


class IhrmEmpCURD():

    # 添加员工

    @classmethod
    def add_emp(cls, header, json_data):
        resp = requests.post(url="https://heimahr.itheima.net/api/sys/user",
                             headers=header, json=json_data)
        return resp

    # # 查询员工
    # @classmethod
    # def query_emp(cls, emp_id, headers):
    #     resp = requests.get(url=f"https://heimahr.itheima.net/api/sys/user/" + emp_id,
    #                         headers=headers)
    #     return resp
    #
    # # 修改员工
    # @classmethod
    # def modify_emp(cls, emp_id, headers, json_data):
    #     resp = requests.put(url=f"https://heimahr.itheima.net/api/sys/user/" + emp_id,
    #                         headers=headers, json=json_data)
    #     return resp
    #
    # # 删除员工
    # @classmethod
    # def delete_emp(cls, emp_id, headers):
    #     resp = requests.delete(url=f"https://heimahr.itheima.net/api/sys/user/" + emp_id,
    #                            headers=headers)
    #     return resp

    # if __name__ == '__main__':
    #     header_add = {"Content-Type": "application/json",
    #                   "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTczNDc3MjQxNiwiZXhwIjoxNzM0Nzk0MDE2fQ.6ej5B6xFzrg4VipUzLWRJGb2KR79U_V5jXmC91E1BDw"}
    #     json_data = {
    #         "username": "齐天五圣",
    #         "mobile": "13349686897",
    #         "workNumber": "",
    #         "formOfEmployment": 1,
    #         "departmentId": 2,
    #         "timeOfEntry": "2024-12-05",
    #         "correctionTime": "2024-12-11T16:00:00.000Z",
    #         "staffPhoto": ""
    #     }
    #     # resp = IhrmEmpCURD.add_emp(header_add, json_data)
    #     # print(添加：",resp.json())
    #
    #     emp_id = "38"
    #     resp1 = IhrmEmpCURD.query_emp(emp_id, header_add)
    #     print("查询：", resp1.json())
    #
    #     data = {
    #         "id": emp_id,
    #         "mobile": "13349686897",
    #         "staffPhoto": "",
    #         "username": "齐天十圣",
    #         "workNumber": "HEIMA00036",
    #         "timeOfEntry": "2024-12-05",
    #         "correctionTime": "2024-12-12",
    #         "departmentId": 3,
    #         "departmentName": "总裁办",
    #         "formOfEmployment": 1,
    #         "roleIds": []
    #     }
    #     resp = IhrmEmpCURD.modify_emp(emp_id, header_add, data)
    #     print("修改：", resp.json())
    #
    #     resp = IhrmEmpCURD.delete_emp(emp_id, header_add)
    #     print("删除：",resp.json())

    @classmethod
    def query_emp(cls, emp_id, header):
        # url =
        resp = requests.get(url="https://heimahr.itheima.net/api/sys/user/" + emp_id, headers=header)
        return resp
